package zy1219.zy5;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.ArrayList;
import java.util.List;

public class demo {
    static List<student> slist = new ArrayList<>();
    public static void main(String[] args) throws DocumentException {
        SAXReader reader = new SAXReader();
        Document read = reader.read("D:\\ideadashuju12\\liu_ya_kai\\src\\zy1219\\zy5\\student.xml");
        Element root = read.getRootElement();
        List<Element> list = root.elements();
        for (Element e : list) {
            slist.add(new student(e.attributeValue("stuNo"),e.elementText("name")
                    ,Integer.parseInt(e.elementText("age")),e.elementText("sex"),Integer.parseInt(e.elementText("score"))));
        }
        for (student s : slist) {
            System.out.println(s);
        }
    }
}
